package com.qfedu.luck.controller;

import com.alibaba.fastjson.JSON;
import com.qfedu.luck.service.LuckService;
import com.qfedu.luck.service.impl.LuckServiceImpl;
import com.qfedu.luck.vo.R;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @program: LuckStudy
 * @description:
 * @author: Feri(邢朋辉)
 * @create: 2021-02-24 15:04
 */
@WebServlet("api/luck/add.do")
public class LuckAddController extends HttpServlet {
    private LuckService service=new LuckServiceImpl();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String u=req.getParameter("uid");
        if(u!=null && u.length()>0){
            int uid=Integer.parseInt(u);
            R r=service.add(uid);
            resp.setContentType("application/json;charset=UTF-8");
            resp.getWriter().print(JSON.toJSONString(r));
        }
    }
}
